<?php
namespace WinZ\DataMinerBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpKernel\Exception\HttpException;
use WinZ\DataMinerBundle\Entity\Character;
use WinZ\DataMinerBundle\Entity\Server;
use WinZ\DataMinerBundle\Entity\Session;
use WinZ\DataMinerBundle\Entity\Node;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;

/**
 * User controller.
 */
class TestController extends Controller
{
     /*
      */        
    public function indexAction($name = 'Toto')
    {
         
       $em = $this->getDoctrine()
           ->getEntityManager();
        $serv = $em->getRepository('DataMinerBundle:Server')->find(6);
        $char = $em->getRepository('DataMinerBundle:Character')->findBy(array("name"=> "Discountlady","server"=>$serv));
        
        
        return $this->render('DataMinerBundle:Default:index.html.twig', array('name' => $name));
        
        
        
        
        if($c['server'] && $c['name']) {
            $serv = $em->getRepository('DataMinerBundle:Server')->getByName($c['server']);
            $char = $em->getRepository('DataMinerBundle:Character')->getByNameServer($c['name'],$serv);
            
            $session = $em->getRepository('DataMinerBundle:Session')->getByCharacterCurrent($char);
            $em->persist($session);
        } 
        
        if($c['nodes']) {
            $node = new Node();
            $node->setQty($c['nodes']);
            $node->setSession($session);
            $em->persist($node);
        } 
        

        return $this->render('DataMinerBundle:Default:index.html.twig', array('name' => $name));
    }
}
